package logic

import (
	"context"
	"gorm.io/gorm"
	"house/models"

	"house/houserpc/houserpc"
	"house/houserpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ClassAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewClassAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClassAddLogic {
	return &ClassAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ClassAddLogic) ClassAdd(in *houserpc.ClassAddRequest) (*houserpc.ClassAddResponse, error) {
	// todo: add your logic here and delete this line
	class := models.Class{
		Model: gorm.Model{},
		Name:  in.Name,
	}
	models.DB.Create(&class)
	return &houserpc.ClassAddResponse{
		ClassId: int64(class.ID),
	}, nil
}
